<?php

namespace App\Requests\Hotel;

use App\Models\AdminRole;
use App\Models\Hotel\Hotel;
use App\Requests\BaseRequest;

/**
 * @property int $id 该数据
 * @property string $name 名称
 * @property string $thumbnail 封面
 * @property int $province_id 省ID
 * @property string $province_text 省文本
 * @property int $city_id 市ID
 * @property string $city_text 市文本
 * @property int $district_id 区ID
 * @property string $district_text 区文本
 * @property string $address 详细地址
 * @property float $score 评分
 * @property float $lng 经度
 * @property float $lat 维度
 * @property string $contact_tel 联系电话
 * @property string $desc 描述
 */
class StoreRequest extends BaseRequest
{
    /**
     * 定义规则信息
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'        => 'required|string|max:255|unique:' . Hotel::tableName() . ',name,' . ($this->id ?? 0) . ',id,is_delete,0',
            'thumbnail'   => 'required|string|max:255',
            'area_ids'    => 'required',
            'address'     => 'required|string|max:255',
            'score'       => 'nullable|numeric|min:0',
            'contact_tel' => 'nullable|string|contact_tel',
            'desc'        => 'nullable|string|max:255',
        ];
    }

    /**
     * 定义字段对应的名称
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'id'            => '该数据',
            'name'          => '名称',
            'thumbnail'     => '封面',
            'province_id'   => '省ID',
            'province_text' => '省文本',
            'city_id'       => '市ID',
            'city_text'     => '市文本',
            'district_id'   => '区ID',
            'district_text' => '区文本',
            'address'       => '详细地址',
            'score'         => '评分',
            'lng'           => '经度',
            'lat'           => '维度',
            'contact_tel'   => '联系电话',
            'desc'          => '描述',
        ];
    }
}
